package zero.tech.games.gate.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import zero.tech.core.data.PageBean;
import zero.tech.core.data.Resp;
import zero.tech.core.data.SimpleUser;
import zero.tech.games.common.Code;
import zero.tech.games.entity.games.CfMarquee;
import zero.tech.games.entity.games.Mail;
import zero.tech.games.gate.hot.CfUtil;
import zero.tech.games.gate.hot.MailUtil;
import zero.tech.games.gate.service.api.IExtService;
import zero.tech.games.gate.util.PackageUtil;

@Service
public class ExtServiceImpl implements IExtService{
	@Autowired
	private CfUtil cfUtil;
	@Autowired
	private MailUtil mailUtil;
	@Override
	public Resp listMarquee(SimpleUser simpleUser) {
		List<CfMarquee>cfMarquees=cfUtil.loadHotMarquees();
		return Resp.build(Code.OK, "获取跑马灯列表成功",PackageUtil.packageResListMarquee(cfMarquees));
	}
	@Override
	public Resp mailList(SimpleUser simpleUser, Integer page, Integer pageLength) {
		int uid = simpleUser.getUid();
		PageBean<Mail> pageBean=mailUtil.loadHotMailListByPage(uid,page,pageLength);
		return Resp.build(Code.OK, "获取邮件列表成功",PackageUtil.packageResMailList(pageBean));
	}
	@Override
	@Transactional
	public Resp mailRead(SimpleUser simpleUser, Integer mail_id) {
		return mailUtil.mailRead(simpleUser,mail_id);
	}
	@Override
	@Transactional
	public Resp mailDel(SimpleUser simpleUser, Integer mail_id) {
		return mailUtil.mailDel(simpleUser,mail_id);
	}
}
